package com.tjec.project.projectWorkbench.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.projectWorkbench.domain.BmsAgencyNo;
import com.tjec.project.projectWorkbench.domain.BmsReportNo;
import com.tjec.project.projectWorkbench.service.IBmsAgencyNoService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 招标代理号Controller
 * 
 * @author pangyongfeng
 * @date 2020-07-31
 */
@RestController
@RequestMapping("/projectWorkbench/agencyNo")
public class BmsAgencyNoController extends BaseController
{
    @Autowired
    private IBmsAgencyNoService bmsAgencyNoService;

    /**
     * 查询招标代理号列表
     */
    //PreAuthorize("@ss.hasPermi('projectWorkbench:agencyNo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsAgencyNo bmsAgencyNo)
    {
        startPage();
        List<BmsAgencyNo> list = bmsAgencyNoService.selectBmsAgencyNoList(bmsAgencyNo);
        return getDataTable(list);
    }

    /**
     * 导出招标代理号列表
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:agencyNo:export')")
    @Log(title = "招标代理号", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmsAgencyNo bmsAgencyNo)
    {
        List<BmsAgencyNo> list = bmsAgencyNoService.selectBmsAgencyNoList(bmsAgencyNo);
        ExcelUtil<BmsAgencyNo> util = new ExcelUtil<BmsAgencyNo>(BmsAgencyNo.class);
        return util.exportExcel(list, "招标代理号");
    }

    /**
     * 获取招标代理号详细信息
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:agencyNo:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(bmsAgencyNoService.selectBmsAgencyNoByGuid(guid));
    }

    /**
     * 新增招标代理号
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:agencyNo:add')")
    @Log(title = "招标代理号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsAgencyNo bmsAgencyNo)
    {
        return AjaxResult.success(bmsAgencyNoService.insertBmsAgencyNo(bmsAgencyNo));
    }

    /**
     * 修改招标代理号
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:agencyNo:edit')")
    @Log(title = "招标代理号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsAgencyNo bmsAgencyNo)
    {
        return toAjax(bmsAgencyNoService.updateBmsAgencyNo(bmsAgencyNo));
    }

    /**
     * 删除招标代理号
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:agencyNo:remove')")
    @Log(title = "招标代理号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(bmsAgencyNoService.deleteBmsAgencyNoByGuids(guids));
    }
    
    @GetMapping("/checkBmsAgencyNo")
    public AjaxResult checkBmsAgencyNo(BmsAgencyNo bmsAgencyNo)
    {
        return AjaxResult.success(bmsAgencyNoService.checkBmsAgencyNo(bmsAgencyNo));
    }

    /**
     * 更新招标代理历史表状态为“已迁移”
     *
     * @param bmsAgencyNo
     * @return
     */
    @Log(title = "招标代理历史数据迁移", businessType = BusinessType.UPDATE)
    @PutMapping("/updateBmsAgencyNoHistory")
    public AjaxResult updateBmsAgencyNoHistory(@RequestBody BmsAgencyNo bmsAgencyNo)
    {
        return AjaxResult.success(bmsAgencyNoService.updateBmsAgencyNoHistory(bmsAgencyNo));
    }
}
